//
//  CGQlishiCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/4/7.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit


class CGQlishiCell: SYBaseCell {

    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor.white
        v.layer.cornerRadius = 5.autoWidth()
        v.layer.masksToBounds = true
        return v
    }()
    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 14.autoBoldFontSize()
        v.text = "设备离线"
        return v
    }()
    
    let duankou: CGQlishiView = {
        let v = CGQlishiView()
        v.title.text = "来源ip："
        v.num.text = "设备编号："
        return v
    }()
    
    let xieyi: CGQlishiView = {
        let v = CGQlishiView()
        v.title.text = "来源端口："
        v.num.text = "设备编号："
        return v
    }()
    
    let beizhu: CGQlishiView = {
        let v = CGQlishiView()
        v.title.text = "数据："
        v.num.text = "232312080700000101007315031A12051F0C000101000100000000000A01000100000000000B02000100000000000C03000100000000000601010302000000000602010302000000000603010302000000000604010302000000000605010302000000000606010302000000000607010302000000000E0101030100000000002424"
        return v
    }()
    

    public func configureView(model: NSlishishujuRecordsModel) {
//        title.text = model.name
//        if let p = model.imgPath {
//            pic.kf.setImage(with: URL(string: IMGIP+p))
//        }
        
        title.text = model.receiveTime
        duankou.num.text = model.fromIP
        xieyi.num.text = model.portNumber
        beizhu.num.text = model.hexMessage
        
    }
    
    override func initViews() {
        
        self.backgroundColor = .clear
        contentView.addSubview(bgView)
        contentView.addSubview(title)
        contentView.addSubview(duankou)
        contentView.addSubview(xieyi)
        contentView.addSubview(beizhu)
        contentView.addSubview(lineView)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10))
            make.bottom.equalToSuperview().offset(-10.autoWidth())
        }
       
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(20))
            make.right.equalToSuperview().offset(autoWidth(-25.0))
            make.height.equalTo(12.autoWidth())
        }
        
       
        duankou.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(63.autoWidth())
            make.left.equalToSuperview().offset(20.autoWidth())
            make.right.equalToSuperview().offset(autoWidth(-20.0))
            make.height.equalTo(13.autoWidth())
        }
        
        xieyi.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(88.autoWidth())
            make.left.equalToSuperview().offset(20.autoWidth())
            make.right.equalToSuperview().offset(autoWidth(-20.0))
            make.height.equalTo(13.autoWidth())
        }
        beizhu.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(113.autoWidth())
            make.left.equalToSuperview().offset(20.autoWidth())
            make.right.equalToSuperview().offset(autoWidth(-20.0))
            make.bottom.equalToSuperview().offset(-27.autoWidth())
        }
        
        lineView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.height.equalTo(0.5.autoWidth())
            make.top.equalToSuperview().offset(autoWidth(40))
        }
    }
}


class CGQlishiView: SYBaseView {
    
    let title: UILabel = {
        let v = UILabel()
        v.textAlignment = .right
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x333333)
        return v
    }()
    
    let num: UILabel = {
        let v = UILabel()
        v.numberOfLines = 0
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x666666)
        return v
    }()
    
   
    
    override func initViews() {
        
        addSubview(title)
        addSubview(num)
        
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview()
            make.height.equalTo(13.autoWidth())
        }
        num.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(89.autoWidth())
            make.right.equalToSuperview().offset(-20.autoWidth())
            make.height.greaterThanOrEqualTo(13.autoWidth())
            make.top.equalToSuperview().offset(0.autoWidth())
            make.bottom.equalToSuperview().offset(0.autoWidth())
        }
       
    }
}




